package HuaWei;

import java.util.*;

/**
 * @author fly
 * @create 2021--03--31--22:16
 */
public class huawei1 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        Map<Character,Integer> hash=new HashMap<>();
        while(sc.hasNextLine()){
            String s=sc.nextLine();
            if(s.equals(""))break;
            char c1=s.charAt(0);
            char c2=s.charAt(2);
            int val1=s.charAt(4)-'0';
            int val2=s.charAt(6)-'0';
            if(val1>val2){
                hash.put(c1,hash.getOrDefault(c1,0)+3);
            }else if(val1<val2){
                hash.put(c2,hash.getOrDefault(c2,0)+3);
            }else{
                hash.put(c1,hash.getOrDefault(c1,0)+1);
                hash.put(c2,hash.getOrDefault(c2,0)+1);
            }
        }
        List<Pair> ans=new ArrayList<>();
        for(Map.Entry<Character,Integer> e:hash.entrySet()){
            ans.add(new Pair(e.getKey(),e.getValue()));
        }
        Collections.sort(ans, new Comparator<Pair>() {
            @Override
            public int compare(Pair o1, Pair o2) {
                if(o1.val>o2.val){
                    return -1;
                }else if(o1.val<o2.val){
                    return 1;
                }else{
                    return o1.ch-o2.ch;
                }
            }
        });
        for(int i=0;i<ans.size();i++){
            Pair p=ans.get(i);
            if(i<ans.size()-1){
                System.out.print(p.ch+" "+p.val+",");
            }else{
                System.out.print(p.ch+" "+p.val);
            }
        }
    }
}
class Pair{
    char ch;
    int  val;
    Pair(){

    }
    Pair(char ch,int val){
        this.ch=ch;
        this.val=val;
    }
}
